package com.yami.shop.service.impl;


import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.model.NoticeModel;
import com.yami.shop.dao.NoticeMallMapper;
import com.yami.shop.service.NoticeMallService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 公告管理
 *
 * @author hzm
 * @date 2019-04-18 21:21:40
 */
@Service
@AllArgsConstructor
public class NoticeMallServiceImpl extends ServiceImpl<NoticeMallMapper, NoticeModel> implements NoticeMallService {

    @Autowired
    private NoticeMallMapper noticeMallMapper;

    @Override
    public void orderCloseNotice(String orderId) {
            Map<String, Object> map = new HashMap<>(16);
            NoticeModel model = new NoticeModel();
            model.setNoticeFlag("0");
            model.setNoticeType("99");
            map.put("order_sn",orderId);
            model.setCreatedStamp(new Date());
            model.setNoticeBody(JSONUtil.toJsonStr(map));
            noticeMallMapper.insert(model);
    }

    @Override
    public List<NoticeModel> getlistByNoticeFlag() {
        return noticeMallMapper.getlistByNoticeFlag();
    }

    @Override
    public int updateFlagByIds(List<String> noticeIds) {
        return noticeMallMapper.updateFlagByIds(noticeIds);
    }
}
